#include <locale>
#include <ostream>
#include <sstream>
#include "globals.h"

using namespace std;

vector<string>* split(char* str, const char* separator)
{
	char* token = NULL;
    char* next_token = NULL;
	vector<string>* vec = new vector<string>;
	// Establish string and get the first token:
    token = strtok_s( str, separator, &next_token);
	

    // While there are tokens in the string
    while (token != NULL)
    {
        //printf( " %s\n", token );
		vec->push_back(token);
        token = strtok_s( NULL, separator, &next_token);
	}
	return vec;
}

bool isnumber(const char* numStr)
{
	for(int i = 0; i < strlen(numStr); i++)
	{
		if(!isdigit(numStr[i]))
			return false;
	}
	return true;
}


string GetHostDescription(const sockaddr_in &sockAddr)
{
	ostringstream stream;
	stream << inet_ntoa(sockAddr.sin_addr) << ":" << ntohs(sockAddr.sin_port);
	return stream.str();
}

